﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>患者管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link href="/lobsteruiframe/layuiadmin/layui/css/layui.css" rel="stylesheet" />
    <link href="/lobsteruiframe/layuiadmin/style/admin.css" rel="stylesheet" />
    <script src="/lobsteruiframe/layuiadmin/layui/layui.js"></script>
    <script src="/jslib/jquery-3.4.1.min.js"></script>
    <script src="/jslib/lobster.js"></script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-header layui-form layuiadmin-card-header-auto">
                <div class="layui-input-inline">
                    <div class="layui-form-item">
                        <label class="layui-form-label">查询条件：</label>
                        <div class="layui-input-block">
                            <input class="layui-input" type="text" name="txtPatientName" placeholder="请输入就诊人姓名/证件号码/手机号" />
                        </div>
                    </div>
                </div>
                <div class="layui-input-inline">
                    <div class="layui-form-item">
                        <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-patient-front-search" id="btnSearch" style="vertical-align: top;">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
                        </button>
                    </div>
                </div>
            </div>
            <div class="layui-card-body">
                <table id="MPPatientTable" lay-filter="MPPatientTable"></table>
            </div>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
    lobsterlayui.main(['index', 'layer', 'form', 'element'], {
        data: {
            $layui: null,
            right: null,
            tablepat: null,
        },
        pageload: function (right) {
            this.data.right = right;
            this.data.tablepat = this.loadtablepatient();
            this.initevent();
        },
        initevent() {
            var self = this;
            var form = layui.form;
            form.on("submit(LAY-patient-front-search)", function (data) {
                self.data.tablepat.reload({
                    where: {
                        patientName: data.field.txtPatientName
                    },
                    page: {
                        curr: 1
                    }
                });
            });
        },
        loadtablepatient() {
            var table = layui.table;
            return table.render({
                elem: '#MPPatientTable',
                headers: lobsterlayui.GetHeaderData(),
                where: {
                    patientName: $("#txtPatientName").val()
                },
                height: 'full-120',
                cellMinWidth: 80,
                //size: 'sm',
                //toolbar: '#toolbar',
                url: '/admin/v1/cpatient/GetPatientData',
                page: true,
                ////even: true,
                cols: [[
                    { field: 'PatientId', title: '就诊人编号', width: '100' },
                    { field: 'Name', title: '就诊人姓名', width: '120' },
                    { field: 'Sex', title: '性别', width: '100' },
                    { field: 'CardName', title: '证件类型', width: '120' },
                    { field: 'IDCard', title: '证件号码', width: '180', templet: '#IDNumberTpl' },
                    { field: 'Birthday', title: '出生日期', width: '180', templet: '#birthday' },
                    { field: 'Phone', title: "手机号码", width: "120", templet: '#TelephoneTpl' },
                    { field: 'CreateMPUserId', title: '创建账号', width: "120" },
                    { field: 'CreateDate', title: '操作时间', width: "180", templet: '#createdate' }
                ]],
                parseData: function (res) {
                    return {
                        code: res.code,
                        msg: res.msg,
                        count: res.data.totalCount,
                        data: res.data.patList
                    }
                }
            });
        },
    });

    /**
    * 关键信息隐藏
    * param str 字符串
    * param frontLen 字符串前面保留位数
    * param endLen 字符串后面保留位数
    * returns {string}
    */
    function hideCode(str, frontLen, endLen) {
        var len = str.length - frontLen - endLen;
        var xing = '';
        for (var i = 0; i < len; i++) {
            xing += '*';
        }
        return str.substring(0, frontLen) + xing + str.substring(str.length - endLen);
    }
</script>

<script type="text/html" id="birthday">
    {{ layui.util.toDateString(new Date(d.Birthday).getTime(), 'yyyy-MM-dd') }}
</script>
<script type="text/html" id="IDNumberTpl">
    {{ hideCode(d.IDCard,4,4) }}
</script>
<script type="text/html" id="TelephoneTpl">
    {{ hideCode(d.Phone,3,2) }}
</script>
<script type="text/html" id="createdate">
    {{ d.CreateDate.replace('T',' ')}}
</script>
<script type="text/html" id="flagTpl">
    {{#  if(d.StrDelFlag == '已解绑'){ }}
    <span style="color:red;">{{ d.StrDelFlag }}</span>
    {{#  } else { }}
    {{ d.StrDelFlag }}
    {{#  } }}
</script>